//
//  component_effect
//  Created by tom on 2022/4/25.
//  Copyright ©xcar. All rights reserved.
//

import 'package:fish_redux/fish_redux.dart';

/// 通用组件Actions
enum CommonComponentAction {
  custom, //custom
}

class CommonComponentActionCreator {
  /// 组件事件
  static Action customAction(Map<String, dynamic> data, String actionKey) {
    data['currentAction'] = actionKey;
    return Action(CommonComponentAction.custom, payload: data);
  }
}

Effect<Map<String, dynamic>>? buildEffect() {
  return combineEffects(<Object, Effect<Map<String, dynamic>>>{
    CommonComponentAction.custom: _customAction,
  });
}

void _customAction(Action action, Context<Map<String, dynamic>> ctx) {
  final Map<String, dynamic> json = action.payload as Map<String, dynamic>;
  final String actionKey = json['currentAction'] as String;
  print('触发相应 actions=$actionKey');
}
